//
//  CHDockCell.m
//  CarFile
//
//  Created by 陈浩 on 2017/7/11.
//  Copyright © 2017年 陈浩. All rights reserved.
//

#import "CHDockCell.h"
@interface CHDockCell ()
@property (nonatomic ,strong) UILabel *titleLabel;

@property (nonatomic ,strong) UILabel *whLabel;

@property (nonatomic ,strong) UILabel *dockLabel;   // 对接

@property (nonatomic ,strong) UILabel *levelLabel;  // 类别

@property (nonatomic ,strong) UILabel *wayLabel;  //  对接形式

@property (nonatomic ,strong) UIView *bgView;

@end
@implementation CHDockCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

+(instancetype)cellForTableView:(UITableView *)tableView{
    static NSString *ID = @"CHDockCell";
    CHDockCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[CHDockCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = KRGB(239, 239, 249);
        [self setupUI];
    }
    return self;
    
}

-(void)setupUI{
    
    self.bgView = [[UIView alloc] init];
    self.bgView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.bgView];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.font =  [UIFont fontWithName:@"Helvetica-Bold" size:14];
    [self.bgView addSubview:self.titleLabel];
    
    self.whLabel = [[UILabel alloc] init];
    self.whLabel.font = [UIFont systemFontOfSize:12];
    self.whLabel.textColor = [UIColor colorWithHexString:@"666666" alpha:1.0f];
    [self.bgView addSubview:self.whLabel];
    
    self.dockLabel = [[UILabel alloc] init];
    self.dockLabel.font = [UIFont systemFontOfSize:12];
    self.dockLabel.textColor = [UIColor colorWithHexString:@"666666" alpha:1.0f];
    [self.bgView addSubview:self.dockLabel];
    
    self.levelLabel = [[UILabel alloc] init];
    self.levelLabel.font = [UIFont systemFontOfSize:12];
    self.levelLabel.textColor = [UIColor colorWithHexString:@"666666" alpha:1.0f];
    [self.bgView addSubview:self.levelLabel];
    
    self.wayLabel = [[UILabel alloc] init];
    self.wayLabel.font = [UIFont systemFontOfSize:12];
    self.wayLabel.textColor = [UIColor colorWithHexString:@"666666" alpha:1.0f];
    [self.bgView addSubview:self.wayLabel];
}


-(void)setModel:(QY_Model *)model{
    _model = model;
    
    self.titleLabel.text = model.name;
    NSString *txt = nil;
    if ([model.xxwh isEqualToString:@"1"]) {
        txt = @"维护";
    }else{
        txt = @"未维护";
    }
    self.whLabel.text = [NSString stringWithFormat:@"信息维护：%@",txt];
    txt = nil;
    if ([model.levels isEqualToString:@"01"]) {
        txt = @"一类";
    }else if ([model.levels isEqualToString:@"02"]){
        txt = @"二类";
    }else{
        txt = @"三类";
    }
    self.levelLabel.text = [NSString stringWithFormat:@"业务类别：%@",txt];
    txt = nil;
    if ([model.state isEqualToString:@"1"]) {
        txt = @"已对接";
        self.wayLabel.text = [NSString stringWithFormat:@"对接形式：%@",model.dock];
    }else{
        txt = @"未对接";
    }
    self.dockLabel.text = [NSString stringWithFormat:@"数据对接：%@",txt];
    
   
    
    
    
}



-(void)layoutSubviews{
    [super layoutSubviews];
    self.bgView.frame = CGRectMake(0, 0, UIScreenW, 90);
    self.titleLabel.frame = CGRectMake(15, 10, UIScreenW - 30, 30);
    self.whLabel.frame = CGRectMake(15, CGRectGetMaxY(self.titleLabel.frame),( UIScreenW - 30)/2, 20);
    self.levelLabel.frame = CGRectMake(CGRectGetMaxX(self.whLabel.frame), CGRectGetMaxY(self.titleLabel.frame), ( UIScreenW - 30)/2, 20);
    self.dockLabel.frame = CGRectMake(15, CGRectGetMaxY(self.whLabel.frame),( UIScreenW - 30)/2, 20);
    self.wayLabel.frame = CGRectMake(CGRectGetMaxX(self.dockLabel.frame), CGRectGetMaxY(self.whLabel.frame), ( UIScreenW - 30)/2, 20);
    
    
}

@end
